Virtual switches are an essential part of realizing networking virtualization. Virtual switches interconnect virtual machines residing on the same host without the need of additional networking hardware. They are also used to connect the virtual machines to the physical network.
The main and basic function of virtual switches is the same as hardware switches, namely layer 2 switching. When a packet arrives at an ingress port of the switch, the switch forwards the packet to an egress port based on the destination MAC addresses and optionally VLAN ID.
Hardware switches maintain a table that maps destination MAC and VLAN ID to the egress port. When a packet comes in, the switch looks for a match in the table with destination MAC and VLAN ID as a key. If a match is found, the switch sends out the packet through the destination port specified in the table entry. In the hardware, this table lookup operation is very fast using a special type of memory called Content Addressable Memory (CAM). With the use of CAM, the lookup is done in a single operation (lookup). Performing the above-explained switching operation in pure software using commodity servers is inherently slower without the lack of specialized hardware support.